In [ ]:
%matplotlib inline
from matplotlib import pylab as plt
from matplotlib.colors import LinearSegmentedColormap
from geonotebook.wrappers import RasterData, VectorData
import numpy as np
from IPython.display import display, Image

Subsetting points


In [ ]:
EXPECTED="https://data.kitware.com/api/v1/item/58a3290d8d777f0721a5ce45/download"
# Set the center of the map to the location the data
M.set_center(-120.32, 47.84, 8)

# Clean up any layers that might already exist
M.layers.annotation.clear_annotations()
for l in M.layers:
    M.remove_layer(l)

rd = RasterData('data/WELD.tif')

M.add_layer(rd[1, 2, 3])
M.add_annotation('point', [-120.32, 47.84])

display(Image(EXPECTED, format="png"))

In [ ]:
layer, data = next(M.layers.annotation.points[0].data)
assert layer == M.layers[0]
assert all(np.isclose(data, [0.302, 0.3003, 0.2517], atol=10e-4))
data

Subsetting rectangles


In [ ]:
EXPECTED="https://data.kitware.com/api/v1/item/58a329148d777f0721a5ce69/download"
# Set the center of the map to the location the data
M.set_center(-120.533, 47.975, 12)

# Clean up any layers that might already exist
M.layers.annotation.clear_annotations()
for l in M.layers:
    M.remove_layer(l)

rd = RasterData('data/WELD.tif')

M.add_layer(rd[1, 2, 3])
M.add_annotation('rectangle', [[-120.588, 47.932], [-120.588, 48.017], [-120.478, 48.017], [-120.478, 47.932]])

display(Image(EXPECTED, format="png"))

In [ ]:
layer, data = next(M.layers.annotation.rectangles[0].data)
assert layer == M.layers[0]
assert data.shape == (113, 146, 3)
assert all(np.isclose(data[0, 0, :], [0.0712, 0.0848, 0.0701], atol=10e-4))
plt.imshow(data)

Subsetting polygons


In [ ]:
EXPECTED="https://data.kitware.com/api/v1/item/58a346848d777f0721a61039/download"
# Set the center of the map to the location the data
M.set_center(-120.533, 47.975, 12)

# Clean up any layers that might already exist
M.layers.annotation.clear_annotations()
for l in M.layers:
    M.remove_layer(l)

rd = RasterData('data/WELD.tif')

M.add_layer(rd[1, 2, 3])
M.add_annotation('polygon', [
    [-120.588, 47.932], [-120.643, 47.975], [-120.588, 48.017], [-120.478, 48.017], [-120.423, 47.975], [-120.478, 47.932]
])

display(Image(EXPECTED, format="png"))

In [ ]:
layer, data = next(M.layers.annotation.polygons[0].data)
assert layer == M.layers[0]
assert data.shape == (113, 292, 3)
assert all(np.isclose(data[55, 150, :], [0.0777, 0.0855, 0.0752], atol=10e-4))
plt.imshow(data)

Subsetting vector data


In [ ]:
M.set_center(-119.63, 47.686, 8)

M.layers.annotation.clear_annotations()
for l in M.layers:
    M.remove_layer(l)
    
rd = RasterData('data/WELD.tif')
M.add_layer(rd[1, 2, 3])

v = VectorData('data/wa_county')
M.add_layer(v)

In [ ]:
county = v.polygons.next()
_, data = county.data.next()
plt.imshow(data)